package ntu.edu.cn.action;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Morven Qiu on 8/8/2016.
 */

public class ScoreAction extends BaseAction {


    private static Logger logger = Logger.getLogger(ScoreAction.class);
    /**
     * this method is aim to check the user information
     * @throws Exception
     */
    public void queryScore() throws Exception{
        HttpPost httpPost = new HttpPost("http://jwgl.ntu.edu.cn/cjcx/Data/ScoreAllData.aspx");
        try(CloseableHttpClient httpClient = getClosableHttpClient()) {
            HttpResponse re = httpClient.execute(httpPost);
            getWriter().print(EntityUtils.toString(re.getEntity()));
        }catch (Exception e){
            logger.error("something is error to get data ");
            getWriter().print("error");
        }
    }

}
